import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import junit.framework.TestCase;
import org.springframework.util.CollectionUtils;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;

public class TyyTest extends TestCase {
    private ThreadLocal<List<Long>> threadLocal = new ThreadLocal<>();
    public static final Set SET = ImmutableSet.of(BigDecimal.class, 1, 2, 3, 4);
    public static final List list = ImmutableList.of(0, 1, 2, 3, 4);
    public static final Map<String, String> MAP = ImmutableMap.of("hello", "world");
    public static final Map<String, String> MAP2 = ImmutableMap.<String, String>builder().put("a", "aa").build();

    /*@Test
    public void testFoundPropertyNamer() {
        String isName = "isName";
        String getName = "getName";
        String getnMetaType = "getnMetaType";
        String getNMetaType = "getNMetaType";

        Stream.of(isName,getName,getnMetaType,getNMetaType)
                .forEach(methodName->System.out.println("方法名字是:"+methodName+" 属性名字:"+ PropertyNamer.methodToProperty(methodName)));
    }*/
    public void test3() {
        Map<String, Object> map = new HashMap<>();
        map.put("a", 1);
        map = Collections.synchronizedMap(map);
        map.put("a2", 1);
        map.put("a3", 1);
        System.out.println(map);

//        List list = new ArrayList();
//        list.add(1);
//        list.add(2);
//        list.add(5, 5);
        System.out.println("list = " + list);
        System.out.println("SET = " + SET);
        System.out.println("MAP = " + MAP);

    }

    public void test2() {
        List<Long> list = new ArrayList<>();
        list.add(1L);
        list.add(2L);
        list.add(3L);
        threadLocal.set(list);
        List<List<Long>> listList = new ArrayList<>();
        listList.add(list);
        List<Long> msgIds = threadLocal.get();
        if (CollectionUtils.isEmpty(msgIds)) {
            msgIds = new ArrayList<>();
            threadLocal.set(msgIds);
        }
        msgIds.add(11L);
        System.out.println("threadLocal.get() = " + threadLocal.get());
        System.out.println("listList = " + listList);
    }

    public void test() {
        TyyTest tyyTest = new TyyTest();
        TyyTest tyyTest2 = new TyyTest();
        TyyTest tyyTest3 = tyyTest;
        System.out.println("tyyTest2 = " + tyyTest.equals(tyyTest2));
        System.out.println("tyyTest31 = " + tyyTest.equals(tyyTest3));
        System.out.println("tyyTest32 = " + (tyyTest == tyyTest3));

        String str = "你\u200F\u200F\u200D\u200E\u200F\u200D\u200C\u200B\u200F\u200C\u200C\u200C\u200E\u200E\u200F好";
        System.out.println("str.length() = " + str.equals(""));
    }

    public static void main(String[] args) {

//    }
//    public void test(){
//        String s1 = new String("11");
//        String s2 = s1.intern();
//        String s3 = "11";
//        System.out.println("s1 == s2 = " + (s1 == s2)); //f
//        System.out.println("s1 == s3 = " + (s1 == s3)); //f
//        System.out.println("s2 == s3 = " + (s2 == s3)); //t

        String s1 = String.valueOf(11);
        String s2 = "111".intern();
        String s3 = "11";
        String s4 = String.valueOf(11);
        String s6 = s4.intern();
        String s5 = "11";
        System.out.println("s1 == s2 = " + (s1 == s2)); //t
        System.out.println("s1 == s3 = " + (s1 == s3)); //t
        System.out.println("s2 == s3 = " + (s2 == s3)); //t
        System.out.println(("" == "")); //t
        System.out.println((s4 == s1)); //f
        System.out.println((s5 == s1)); //t
        System.out.println((s5 == s3)); //t
        System.out.println((s5 == s4)); //f
        System.out.println((s5 == s6)); //t
        System.out.println((s4 == s6)); //f
        System.out.println((s1 == s6)); //t
    }
}
